package com.tingyuge.base.arithmetic.sort;

/**
 * Created by xiaodao
 * date: 2020/4/5
 */
public class BubblingSort1<T extends Comparable<T>> extends Sort {
    @Override
    protected void sort() {
        for (int j = array.length - 1; j > 0; j--) {
            //每次循环找到上次排好的倒数前一位就可以
            for (int i = 1; i <= j; i++) {

                if (cmp(i,i-1)<0) {
//                    int temp = array[i];
//                    array[i] = array[i - 1];
//                    array[i - 1] = temp;

                    swap(i,i-1);

                }

            }
        }
    }
}
